﻿using Framework.Models.Entities;
using Framework.Repository.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Framework.Repository
{
    public class RelevanceRepository : Repository<Fw_Relevance, string>, IRelevanceRepository
    {
        public RelevanceRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
        {
        }

        public List<string> Get(string key, bool returnSecondIds, params string[] ids)
        {
            if (returnSecondIds)
            {
                return QueryAsNoTracking(u => u.Key == key && ids.Contains(u.FirstId)).Select(u => u.SecondId).ToList();
            }
            else
            {
                return QueryAsNoTracking(u => u.Key == key
                                            && ids.Contains(u.SecondId)).Select(u => u.FirstId).ToList();
            }
        }

    }
}
